package live.testdemo.bazi.common.body;

import com.nlf.calendar.Solar;
import live.testdemo.bazi.common.constants.Sex;

import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by chentz on 2017/10/19.
 */
public class BaziUtil {
    public final static String[] Gan = {"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"};
    public final static String[] Zhi = {"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"};
    public static final String[] jiazhi = {
            "甲子", "乙丑", "丙寅", "丁卯", "戊辰", "己巳", "庚午", "辛未", "壬申", "癸酉",
            "甲戌", "乙亥", "丙子", "丁丑", "戊寅", "己卯", "庚辰", "辛巳", "壬午", "癸未",
            "甲申", "乙酉", "丙戌", "丁亥", "戊子", "己丑", "庚寅", "辛卯", "壬辰", "癸巳",
            "甲午", "乙未", "丙申", "丁酉", "戊戌", "己亥", "庚子", "辛丑", "壬寅", "癸卯",
            "甲辰", "乙巳", "丙午", "丁未", "戊申", "己酉", "庚戌", "辛亥", "壬子", "癸丑",
            "甲寅", "乙卯", "丙辰", "丁巳", "戊午", "己未", "庚申", "辛酉", "壬戌", "癸亥"
    };
    final static String[] chineseNumber = {"正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "腊"};
    final static long[] lunarInfo = new long[]{0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2,
                                               0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977,
                                               0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970,
                                               0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950,
                                               0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557,
                                               0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5d0, 0x14573, 0x052d0, 0x0a9a8, 0x0e950, 0x06aa0,
                                               0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0,
                                               0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b5a0, 0x195a6,
                                               0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570,
                                               0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x055c0, 0x0ab60, 0x096d5, 0x092e0,
                                               0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5,
                                               0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930,
                                               0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530,
                                               0x05aa0, 0x076a3, 0x096d0, 0x04bd7, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45,
                                               0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0
    };
    static SimpleDateFormat chineseDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    //注意数组没有第5行和第5列
    public final String[][] resultarray = {
            {"伏位", "绝命", "天医", "生气", "六煞", "祸害", "五鬼", "延年"},
            {"绝命", "伏位", "祸害", "五鬼", "延年", "天医", "生气", "六煞"},
            {"天医", "祸害", "伏位", "延年", "五鬼", "绝命", "六煞", "生气"},
            {"生气", "五鬼", "延年", "伏位", "祸害", "六煞", "绝命", "天医"},
            {"六煞", "延年", "五鬼", "祸害", "伏位", "生气", "天医", "绝命"},
            {"祸害", "天医", "绝命", "六煞", "生气", "伏位", "延年", "五鬼"},
            {"五鬼", "生气", "六煞", "绝命", "天医", "延年", "伏位", "祸害"},
            {"延年", "六煞", "生气", "天医", "绝命", "五鬼", "祸害", "伏位"},};
    public final String[][] numsix = {
            //干支，纳音，岁数，男，女
            {"丙戌", "屋上土", "1", "3", "3"},
            {"乙酉", "泉中水", "2", "4", "2"},
            {"甲申", "泉中水", "3", "5", "1"},
            {"癸未", "杨柳木", "4", "6", "9"},
            {"壬午", "杨柳木", "5", "7", "8"},
            {"辛巳", "白蜡金", "6", "8", "7"},
            {"庚辰", "白蜡金", "7", "9", "6"},
            {"己卯", "城墙土", "8", "1", "5"},
            {"戊寅", "城墙土", "9", "2", "4"},
            {"丁丑", "涧下水", "10", "3", "3"},
            {"丙子", "涧下水", "11", "4", "2"},
            {"乙亥", "山头火", "12", "5", "1"},
            {"甲戌", "山头火", "13", "6", "9"},
            {"癸酉", "剑锋金", "14", "7", "8"},
            {"壬申", "剑锋金", "15", "8", "7"},
            {"辛未", "路旁土", "16", "9", "6"},
            {"庚午", "路旁土", "17", "1", "5"},
            {"己巳", "大林木", "18", "2", "4"},
            {"戊辰", "大林木", "19", "3", "3"},
            {"丁卯", "炉中火", "20", "4", "2"},
            {"丙寅", "炉中火", "21", "5", "1"},
            {"乙丑", "海中金", "22", "6", "9"},
            {"甲子", "海中金", "23", "7", "8"},
            {"癸亥", "大海水", "24", "8", "7"},
            {"壬戌", "大海水", "25", "9", "6"},
            {"辛酉", "石榴木", "26", "1", "5"},
            {"庚申", "石榴木", "27", "2", "4"},
            {"己未", "天上火", "28", "3", "3"},
            {"戊午", "天上火", "29", "4", "2"},
            {"丁巳", "沙中土", "30", "5", "1"},
            {"丙辰", "沙中土", "31", "6", "9"},
            {"乙卯", "大溪水", "32", "7", "8"},
            {"甲寅", "大溪水", "33", "8", "7"},
            {"癸丑", "桑松木", "34", "9", "6"},
            {"壬子", "桑松木", "35", "1", "5"},
            {"辛亥", "钗钏金", "36", "2", "4"},
            {"庚戌", "钗钏金", "37", "3", "3"},
            {"己酉", "大驿土", "38", "4", "2"},
            {"戊申", "大驿土", "39", "5", "1"},
            {"丁未", "天河水", "40", "6", "9"},
            {"丙午", "天河水", "41", "7", "8"},
            {"乙巳", "佛灯火", "42", "8", "7"},
            {"甲辰", "佛灯火", "43", "9", "6"},
            {"癸卯", "金箔金", "44", "1", "5"},
            {"壬寅", "金箔金", "45", "2", "4"},
            {"辛丑", "壁上土", "46", "3", "3"},
            {"庚子", "壁上土", "47", "4", "2"},
            {"己亥", "平地木", "48", "5", "1"},
            {"戊戌", "平地木", "49", "6", "9"},
            {"丁酉", "山下火", "50", "7", "8"},
            {"丙申", "山下火", "51", "8", "7"},
            {"乙未", "沙中金", "52", "9", "6"},
            {"甲午", "沙中金", "53", "1", "5"},
            {"癸巳", "长流水", "54", "2", "4"},
            {"壬辰", "长流水", "55", "3", "3"},
            {"辛卯", "松柏木", "56", "4", "2"},
            {"庚寅", "松柏木", "57", "5", "1"},
            {"己丑", "霹雳火", "58", "6", "9"},
            {"戊子", "霹雳火", "59", "7", "8"},
            {"丁亥", "屋上土", "60", "8", "7"},};
    String[][] shisheng = {
            {"日/干", "甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"},
            {"甲", "比肩", "劫财", "食神", "伤官", "偏财", "正财", "七杀", "正官", "偏印", "正印"},
            {"乙", "劫财", "比肩", "伤官", "食神", "正财", "偏财", "正官", "七杀", "正印", "偏印"},
            {"丙", "偏印", "正印", "比肩", "劫财", "食神", "伤官", "偏财", "正财", "七杀", "正官"},
            {"丁", "正印", "偏印", "劫财", "比肩", "伤官", "食神", "正财", "偏财", "正官", "七杀"},
            {"戊", "七杀", "正官", "偏印", "正印", "比肩", "劫财", "食神", "伤官", "偏财", "正财"},
            {"己", "正官", "七杀", "正印", "偏印", "劫财", "比肩", "伤官", "食神", "正财", "偏财"},
            {"庚", "偏财", "正财", "七杀", "正官", "偏印", "正印", "比肩", "劫财", "食神", "伤官"},
            {"辛", "正财", "偏财", "正官", "七杀", "正印", "偏印", "劫财", "比肩", "伤官", "食神"},
            {"壬", "食神", "伤官", "偏财", "正财", "七杀", "正官", "偏印", "正印", "比肩", "劫财"},
            {"癸", "伤官", "食神", "正财", "偏财", "正官", "七杀", "正印", "偏印", "劫财", "比肩"},};
    String[][] shengwang = {
            {"天干", "长生", "沐浴", "冠带", "临官", "帝旺", "衰", "病", "死", "墓", "绝", "胎", "养"},
            {"甲", "亥", "子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌"},
            {"丙", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥", "子", "丑"},
            {"戊", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥", "子", "丑"},
            {"庚", "巳", "午", "未", "申", "酉", "戌", "亥", "子", "丑", "寅", "卯", "辰"},
            {"壬", "申", "酉", "戌", "亥", "子", "丑", "寅", "卯", "辰", "巳", "午", "未"},
            {"乙", "午", "巳", "辰", "卯", "寅", "丑", "子", "亥", "戌", "酉", "申", "未"},
            {"丁", "酉", "申", "未", "午", "巳", "辰", "卯", "寅", "丑", "子", "亥", "戌"},
            {"己", "酉", "申", "未", "午", "巳", "辰", "卯", "寅", "丑", "子", "亥", "戌"},
            {"辛", "子", "亥", "戌", "酉", "申", "未", "午", "巳", "辰", "卯", "寅", "丑"},
            {"癸", "卯", "寅", "丑", "子", "亥", "戌", "酉", "申", "未", "午", "巳", "辰"},};
    
    /**
     * 返回甲子纳音
     *
     * @param paramString 甲子
     * @return 纳音
     */
    public static String jiazinaying(String paramString) {
        if ((paramString.equals("甲子")) || (paramString.equals("乙丑"))) {
            return "海中金";
        }
        if ((paramString.equals("丙寅")) || (paramString.equals("丁卯"))) {
            return "炉中火";
        }
        if ((paramString.equals("戊辰")) || (paramString.equals("己巳"))) {
            return "大林木";
        }
        if ((paramString.equals("庚午")) || (paramString.equals("辛未"))) {
            return "路旁土";
        }
        if ((paramString.equals("壬申")) || (paramString.equals("癸酉"))) {
            return "剑锋金";
        }
        if ((paramString.equals("甲戌")) || (paramString.equals("乙亥"))) {
            return "山头火";
        }
        if ((paramString.equals("丙子")) || (paramString.equals("丁丑"))) {
            return "涧下水";
        }
        if ((paramString.equals("戊寅")) || (paramString.equals("己卯"))) {
            return "城头土";
        }
        if ((paramString.equals("庚辰")) || (paramString.equals("辛巳"))) {
            return "白蜡金";
        }
        if ((paramString.equals("壬午")) || (paramString.equals("癸未"))) {
            return "杨柳木";
        }
        if ((paramString.equals("甲申")) || (paramString.equals("乙酉"))) {
            return "泉中水";
        }
        if ((paramString.equals("丙戌")) || (paramString.equals("丁亥"))) {
            return "屋上土";
        }
        if ((paramString.equals("戊子")) || (paramString.equals("己丑"))) {
            return "霹雳火";
        }
        if ((paramString.equals("庚寅")) || (paramString.equals("辛卯"))) {
            return "松柏木";
        }
        if ((paramString.equals("壬辰")) || (paramString.equals("癸巳"))) {
            return "长流水";
        }
        if ((paramString.equals("甲午")) || (paramString.equals("乙未"))) {
            return "沙中金";
        }
        if ((paramString.equals("丙申")) || (paramString.equals("丁酉"))) {
            return "山下火";
        }
        if ((paramString.equals("戊戌")) || (paramString.equals("己亥"))) {
            return "平地木";
        }
        if ((paramString.equals("庚子")) || (paramString.equals("辛丑"))) {
            return "壁上土";
        }
        if ((paramString.equals("壬寅")) || (paramString.equals("癸卯"))) {
            return "金箔金";
        }
        if ((paramString.equals("甲辰")) || (paramString.equals("乙巳"))) {
            return "佛灯火";
        }
        if ((paramString.equals("丙午")) || (paramString.equals("丁未"))) {
            return "天河水";
        }
        if ((paramString.equals("戊申")) || (paramString.equals("己酉"))) {
            return "大驿土";
        }
        if ((paramString.equals("庚戌")) || (paramString.equals("辛亥"))) {
            return "钗钏金";
        }
        if ((paramString.equals("壬子")) || (paramString.equals("癸丑"))) {
            return "桑柘木";
        }
        if ((paramString.equals("甲寅")) || (paramString.equals("乙卯"))) {
            return "大溪水";
        }
        if ((paramString.equals("丙辰")) || (paramString.equals("丁巳"))) {
            return "沙中土";
        }
        if ((paramString.equals("戊午")) || (paramString.equals("己未"))) {
            return "天上火";
        }
        if ((paramString.equals("庚申")) || (paramString.equals("辛酉"))) {
            return "石榴木";
        }
        if ((paramString.equals("壬戌")) || (paramString.equals("癸亥"))) {
            return "大海水";
        }
        return "";
    }
    
    /**
     * 地支藏干 子藏癸 卯藏乙 午藏丁己  酉藏辛
     * <p>
     * 寅藏 甲丙戊  巳藏 丙庚戊  申藏 庚壬戊  亥藏 甲壬
     * <p>
     * 丑藏 辛癸己 辰藏 癸乙戊  未藏 乙丁己  戌藏 丁辛戊
     *
     * @param dizhi
     * @return
     */
    public static String[] dizhuang(String dizhi) {
        String[] returnstring = new String[3];
        if (dizhi.equals("子")) {
            returnstring[0] = "癸";
        }
        if (dizhi.equals("卯")) {
            returnstring[0] = "乙";
        }
        
        if (dizhi.equals("午")) {
            returnstring[0] = "丁";
            returnstring[1] = "己";
        }
        
        if (dizhi.equals("酉")) {
            returnstring[0] = "辛";
            
        }
        
        if (dizhi.equals("寅")) {
            returnstring[0] = "甲";
            returnstring[1] = "丙";
            returnstring[2] = "戊";
            
            
        }
        
        if (dizhi.equals("巳")) {
            
            returnstring[0] = "丙";
            returnstring[1] = "庚";
            returnstring[2] = "戊";
        }
        
        if (dizhi.equals("申")) {
            
            returnstring[0] = "庚";
            returnstring[1] = "壬";
            returnstring[2] = "戊";
        }
        
        if (dizhi.equals("亥")) {
            
            returnstring[0] = "甲";
            returnstring[1] = "壬";
            
        }
        
        if (dizhi.equals("丑")) {
            
            returnstring[0] = "辛";
            returnstring[1] = "癸";
            returnstring[2] = "己";
            
        }
        
        if (dizhi.equals("辰")) {
            
            returnstring[0] = "癸";
            returnstring[1] = "乙";
            returnstring[2] = "戊";
            
        }
        
        if (dizhi.equals("未")) {
            
            returnstring[0] = "乙";
            returnstring[1] = "丁";
            returnstring[2] = "己";
            
        }
        
        if (dizhi.equals("戌")) {
            returnstring[0] = "丁";
            returnstring[1] = "辛";
            returnstring[2] = "戊";
            
        }
        
        return returnstring;
        
    }
    
    /**
     * 十天干生旺死绝表
     * <p>
     * 天干 长生 沐浴 冠带 临官 帝旺 衰 病 死 墓 绝 胎 养      *
     * 甲 亥 子 丑 寅 卯 辰 巳 午 未 申 酉 戌
     * 丙 寅 卯 辰 巳 午 未 申 酉 戌 亥 子 丑
     * 戊 寅 卯 辰 巳 午 未 申 酉 戌 亥 子 丑
     * 庚 巳 午 未 申 酉 戌 亥 子 丑 寅 卯 辰
     * 壬 申 酉 戌 亥 子 丑 寅 卯 辰 巳 午 未
     * 乙 午 巳 辰 卯 寅 丑 子 亥 戌 酉 申 未
     * 丁 酉 申 未 午 巳 辰 卯 寅 丑 子 亥 戌
     * 己 酉 申 未 午 巳 辰 卯 寅 丑 子 亥 戌
     * 辛 子 亥 戌 酉 申 未 午 巳 辰 卯 寅 丑
     * 癸 卯 寅 丑 子 亥 戌 酉 申 未 午 巳 辰
     *
     * @param paramString1
     * @param paramString2
     * @return
     */
    public static String shengwang(String paramString1, String paramString2) {
        if (((paramString1.equals("甲")) && (paramString2.equals("亥"))) || ((paramString1.equals("丙")) && (paramString2.equals("寅"))) || ((paramString1.equals("戊")) && (paramString2.equals("寅"))) || ((paramString1.equals("庚")) && (paramString2.equals("巳"))) || ((paramString1.equals("壬")) && (paramString2.equals("申"))) || ((paramString1.equals("乙")) && (paramString2.equals("午"))) || ((paramString1.equals("丁")) && (paramString2.equals("酉"))) || ((paramString1.equals("己")) && (paramString2.equals("酉"))) || ((paramString1.equals("辛")) && (paramString2.equals("子"))) || ((paramString1.equals("癸")) && (paramString2.equals("卯")))) {
            return "长";
        }
        if (((paramString1.equals("甲")) && (paramString2.equals("子"))) || ((paramString1.equals("丙")) && (paramString2.equals("卯"))) || ((paramString1.equals("戊")) && (paramString2.equals("卯"))) || ((paramString1.equals("庚")) && (paramString2.equals("午"))) || ((paramString1.equals("壬")) && (paramString2.equals("酉"))) || ((paramString1.equals("乙")) && (paramString2.equals("巳"))) || ((paramString1.equals("丁")) && (paramString2.equals("申"))) || ((paramString1.equals("己")) && (paramString2.equals("申"))) || ((paramString1.equals("辛")) && (paramString2.equals("亥"))) || ((paramString1.equals("癸")) && (paramString2.equals("寅")))) {
            return "沐";
        }
        if (((paramString1.equals("甲")) && (paramString2.equals("丑"))) || ((paramString1.equals("丙")) && (paramString2.equals("辰"))) || ((paramString1.equals("戊")) && (paramString2.equals("辰"))) || ((paramString1.equals("庚")) && (paramString2.equals("未"))) || ((paramString1.equals("壬")) && (paramString2.equals("戌"))) || ((paramString1.equals("乙")) && (paramString2.equals("辰"))) || ((paramString1.equals("丁")) && (paramString2.equals("未"))) || ((paramString1.equals("己")) && (paramString2.equals("未"))) || ((paramString1.equals("辛")) && (paramString2.equals("戌"))) || ((paramString1.equals("癸")) && (paramString2.equals("丑")))) {
            return "冠";
        }
        if (((paramString1.equals("甲")) && (paramString2.equals("寅"))) || ((paramString1.equals("丙")) && (paramString2.equals("巳"))) || ((paramString1.equals("戊")) && (paramString2.equals("巳"))) || ((paramString1.equals("庚")) && (paramString2.equals("申"))) || ((paramString1.equals("壬")) && (paramString2.equals("亥"))) || ((paramString1.equals("乙")) && (paramString2.equals("卯"))) || ((paramString1.equals("丁")) && (paramString2.equals("午"))) || ((paramString1.equals("己")) && (paramString2.equals("午"))) || ((paramString1.equals("辛")) && (paramString2.equals("酉"))) || ((paramString1.equals("癸")) && (paramString2.equals("子")))) {
            return "临";
        }
        if (((paramString1.equals("甲")) && (paramString2.equals("卯"))) || ((paramString1.equals("丙")) && (paramString2.equals("午"))) || ((paramString1.equals("戊")) && (paramString2.equals("午"))) || ((paramString1.equals("庚")) && (paramString2.equals("酉"))) || ((paramString1.equals("壬")) && (paramString2.equals("子"))) || ((paramString1.equals("乙")) && (paramString2.equals("寅"))) || ((paramString1.equals("丁")) && (paramString2.equals("巳"))) || ((paramString1.equals("己")) && (paramString2.equals("巳"))) || ((paramString1.equals("辛")) && (paramString2.equals("申"))) || ((paramString1.equals("癸")) && (paramString2.equals("亥")))) {
            return "帝";
        }
        if (((paramString1.equals("甲")) && (paramString2.equals("辰"))) || ((paramString1.equals("丙")) && (paramString2.equals("未"))) || ((paramString1.equals("戊")) && (paramString2.equals("未"))) || ((paramString1.equals("庚")) && (paramString2.equals("戌"))) || ((paramString1.equals("壬")) && (paramString2.equals("丑"))) || ((paramString1.equals("乙")) && (paramString2.equals("丑"))) || ((paramString1.equals("丁")) && (paramString2.equals("辰"))) || ((paramString1.equals("己")) && (paramString2.equals("辰"))) || ((paramString1.equals("辛")) && (paramString2.equals("未"))) || ((paramString1.equals("癸")) && (paramString2.equals("戌")))) {
            return "衰";
        }
        if (((paramString1.equals("甲")) && (paramString2.equals("巳"))) || ((paramString1.equals("丙")) && (paramString2.equals("申"))) || ((paramString1.equals("戊")) && (paramString2.equals("申"))) || ((paramString1.equals("庚")) && (paramString2.equals("亥"))) || ((paramString1.equals("壬")) && (paramString2.equals("寅"))) || ((paramString1.equals("乙")) && (paramString2.equals("子"))) || ((paramString1.equals("丁")) && (paramString2.equals("卯"))) || ((paramString1.equals("己")) && (paramString2.equals("卯"))) || ((paramString1.equals("辛")) && (paramString2.equals("午"))) || ((paramString1.equals("癸")) && (paramString2.equals("酉")))) {
            return "病";
        }
        if (((paramString1.equals("甲")) && (paramString2.equals("午"))) || ((paramString1.equals("丙")) && (paramString2.equals("酉"))) || ((paramString1.equals("戊")) && (paramString2.equals("酉"))) || ((paramString1.equals("庚")) && (paramString2.equals("子"))) || ((paramString1.equals("壬")) && (paramString2.equals("卯"))) || ((paramString1.equals("乙")) && (paramString2.equals("亥"))) || ((paramString1.equals("丁")) && (paramString2.equals("寅"))) || ((paramString1.equals("己")) && (paramString2.equals("寅"))) || ((paramString1.equals("辛")) && (paramString2.equals("巳"))) || ((paramString1.equals("癸")) && (paramString2.equals("申")))) {
            return "死";
        }
        if (((paramString1.equals("甲")) && (paramString2.equals("未"))) || ((paramString1.equals("丙")) && (paramString2.equals("戌"))) || ((paramString1.equals("戊")) && (paramString2.equals("戌"))) || ((paramString1.equals("庚")) && (paramString2.equals("丑"))) || ((paramString1.equals("壬")) && (paramString2.equals("辰"))) || ((paramString1.equals("乙")) && (paramString2.equals("戌"))) || ((paramString1.equals("丁")) && (paramString2.equals("丑"))) || ((paramString1.equals("己")) && (paramString2.equals("丑"))) || ((paramString1.equals("辛")) && (paramString2.equals("辰"))) || ((paramString1.equals("癸")) && (paramString2.equals("未")))) {
            return "墓";
        }
        if (((paramString1.equals("甲")) && (paramString2.equals("申"))) || ((paramString1.equals("丙")) && (paramString2.equals("亥"))) || ((paramString1.equals("戊")) && (paramString2.equals("亥"))) || ((paramString1.equals("庚")) && (paramString2.equals("寅"))) || ((paramString1.equals("壬")) && (paramString2.equals("巳"))) || ((paramString1.equals("乙")) && (paramString2.equals("酉"))) || ((paramString1.equals("丁")) && (paramString2.equals("子"))) || ((paramString1.equals("己")) && (paramString2.equals("子"))) || ((paramString1.equals("辛")) && (paramString2.equals("卯"))) || ((paramString1.equals("癸")) && (paramString2.equals("午")))) {
            return "绝";
        }
        if (((paramString1.equals("甲")) && (paramString2.equals("酉"))) || ((paramString1.equals("丙")) && (paramString2.equals("子"))) || ((paramString1.equals("戊")) && (paramString2.equals("子"))) || ((paramString1.equals("庚")) && (paramString2.equals("卯"))) || ((paramString1.equals("壬")) && (paramString2.equals("午"))) || ((paramString1.equals("乙")) && (paramString2.equals("申"))) || ((paramString1.equals("丁")) && (paramString2.equals("亥"))) || ((paramString1.equals("己")) && (paramString2.equals("亥"))) || ((paramString1.equals("辛")) && (paramString2.equals("寅"))) || ((paramString1.equals("癸")) && (paramString2.equals("巳")))) {
            return "胎";
        }
        if (((paramString1.equals("甲")) && (paramString2.equals("戌"))) || ((paramString1.equals("丙")) && (paramString2.equals("丑"))) || ((paramString1.equals("戊")) && (paramString2.equals("丑"))) || ((paramString1.equals("庚")) && (paramString2.equals("辰"))) || ((paramString1.equals("壬")) && (paramString2.equals("未"))) || ((paramString1.equals("乙")) && (paramString2.equals("未"))) || ((paramString1.equals("丁")) && (paramString2.equals("戌"))) || ((paramString1.equals("己")) && (paramString2.equals("戌"))) || ((paramString1.equals("辛")) && (paramString2.equals("丑"))) || ((paramString1.equals("癸")) && (paramString2.equals("辰")))) {
            return "养";
        }
        return "";
    }
    
    /**
     * 判断相害 地支六害 子未害 丑午害 寅巳害 卯辰害 申亥害 酉戌害
     *
     * @param paramString1
     * @param paramString2
     * @return
     */
    public static boolean xianghai(String paramString1, String paramString2) {
        return ((paramString1.equals("子")) && (paramString2.equals("未"))) || ((paramString1.equals("未")) && (paramString2.equals("子"))) || ((paramString1.equals("丑")) && (paramString2.equals("午"))) || ((paramString1.equals("午")) && (paramString2.equals("丑"))) || ((paramString1.equals("寅")) && (paramString2.equals("巳"))) || ((paramString1.equals("巳")) && (paramString2.equals("寅"))) || ((paramString1.equals("卯")) && (paramString2.equals("辰"))) || ((paramString1.equals("辰")) && (paramString2.equals("卯"))) || ((paramString1.equals("戌")) && (paramString2.equals("酉"))) || ((paramString1.equals("酉")) && (paramString2.equals("戌"))) || ((paramString1.equals("申")) && (paramString2.equals("亥"))) || ((paramString1.equals("亥")) && (paramString2.equals("申")));
    }
    
    /**
     * 地支相刑 子卯刑 寅巳申刑 丑未戌刑 辰午丑亥自刑
     *
     * @param paramString1
     * @param paramString2
     * @return
     */
    public static boolean xiangxing(String paramString1, String paramString2) {
        return ((paramString1.equals("子")) && (paramString2.equals("卯"))) || ((paramString1.equals("卯")) && (paramString2.equals("子"))) || ((paramString1.equals("丑")) && (paramString2.equals("未"))) || ((paramString1.equals("未")) && (paramString2.equals("丑"))) || ((paramString1.equals("丑")) && (paramString2.equals("戌"))) || ((paramString1.equals("戌")) && (paramString2.equals("丑"))) || ((paramString1.equals("未")) && (paramString2.equals("戌"))) || ((paramString1.equals("戌")) && (paramString2.equals("未"))) || ((paramString1.equals("巳")) && (paramString2.equals("申"))) || ((paramString1.equals("申")) && (paramString2.equals("巳"))) || ((paramString1.equals("巳")) && (paramString2.equals("寅"))) || ((paramString1.equals("寅")) && (paramString2.equals("巳"))) || ((paramString1.equals("申")) && (paramString2.equals("寅"))) || ((paramString1.equals("寅")) && (paramString2.equals("申"))) || ((paramString1.equals("辰")) && (paramString2.equals("辰"))) || ((paramString1.equals("午")) && (paramString2.equals("午"))) || ((paramString1.equals("酉")) && (paramString2.equals("酉"))) || ((paramString1.equals("亥")) && (paramString2.equals("亥")));
    }
    
    /**
     * 子、寅、辰、午、申、戌为阳支；丑卯巳未酉亥为阴支
     *
     * @param paramString
     * @return
     */
    public static String yinyang(String paramString) {
        if ((paramString.equals("子")) || (paramString.equals("寅")) || (paramString.equals("辰")) || (paramString.equals("午")) || (paramString.equals("申")) || (paramString.equals("戌"))) {
            return "阳";
        }
        if ((paramString.equals("丑")) || (paramString.equals("卯")) || (paramString.equals("巳")) || (paramString.equals("未")) || (paramString.equals("酉")) || (paramString.equals("亥"))) {
            return "阴";
        }
        return "";
    }
    
    /**
     * 天干五行 甲乙同属木, 甲为阳, 乙为阴 丙丁同属火, 丙为阳, 丁为阴 戊己同属土, 戊为阳, 己为阴 庚辛同属金, 庚为阳, 辛为阴
     * 壬癸同属水, 壬为阳, 癸为阴
     *
     * @param paramString
     * @return
     */
    public static String tianganwuxing(String paramString) {
        if ((paramString.equals("甲")) || (paramString.equals("乙"))) {
            return "木";
        }
        if ((paramString.equals("丙")) || (paramString.equals("丁"))) {
            return "火";
        }
        if ((paramString.equals("戊")) || (paramString.equals("己"))) {
            return "土";
        }
        if ((paramString.equals("庚")) || (paramString.equals("辛"))) {
            return "金";
        }
        if ((paramString.equals("壬")) || (paramString.equals("癸"))) {
            return "水";
        }
        return "";
    }
    
    /**
     * 地支五行 亥子属水，巳午属火，寅卯属木，申酉属金，辰丑未戌属土，丑未为阴土，辰戌为阳土，辰丑为湿土，未戌为燥土。
     *
     * @param paramString
     * @return
     */
    public static String dizhiwuxing(String paramString) {
        if ((paramString.equals("寅")) || (paramString.equals("卯"))) {
            return "木";
        }
        if ((paramString.equals("巳")) || (paramString.equals("午"))) {
            return "火";
        }
        if ((paramString.equals("丑")) || (paramString.equals("辰")) || (paramString.equals("未")) || (paramString.equals("戌"))) {
            return "土";
        }
        if ((paramString.equals("申")) || (paramString.equals("酉"))) {
            return "金";
        }
        if ((paramString.equals("亥")) || (paramString.equals("子"))) {
            return "水";
        }
        return "";
    }
    
    /**
     * 甲、丙、戊、庚、壬为阳；乙、丁、己、辛、癸为阴
     *
     * @param paramString
     * @return
     */
    public static String tianganyinyang(String paramString) {
        if ((paramString.equals("甲")) || (paramString.equals("丙")) || (paramString.equals("戊")) || (paramString.equals("庚")) || (paramString.equals("壬"))) {
            return "阳";
        }
        if ((paramString.equals("乙")) || (paramString.equals("丁")) || (paramString.equals("己")) || (paramString.equals("辛")) || (paramString.equals("癸"))) {
            return "阴";
        }
        return "";
    }
    
    /**
     * 桃花位:
     *
     * @param
     */
    public static void taohua(String[] bazi) {
        String returnString = null;
        if ((bazi[2].equals("寅")) || (bazi[2].equals("午")) || (bazi[2].equals("戌"))) {
            returnString += "卯";
        }
        if ((bazi[2].equals("申")) || (bazi[2].equals("子")) || (bazi[2].equals("辰"))) {
            returnString += "酉";
        }
        if ((bazi[2].equals("亥")) || (bazi[2].equals("卯")) || (bazi[2].equals("未"))) {
            returnString += "子";
        }
        if ((bazi[2].equals("巳")) || (bazi[2].equals("酉")) || (bazi[2].equals("丑"))) {
            returnString += "午";
        }
    }
    
    /**
     * 六十甲子太岁神
     *
     * @param paramString 年柱
     * @return
     */
    public static String tianshui(String paramString) {
        if (paramString.equals("甲子")) {
            return "金办将军";
        }
        if (paramString.equals("乙丑")) {
            return "陈材将军";
        }
        if (paramString.equals("丙寅")) {
            return "耿章将军";
        }
        if (paramString.equals("丁卯")) {
            return "沈兴将军";
        }
        if (paramString.equals("戊辰")) {
            return "赵达将军";
        }
        if (paramString.equals("己巳")) {
            return "郭灿将军";
        }
        if (paramString.equals("庚午")) {
            return "王清将军";
        }
        if (paramString.equals("辛未")) {
            return "李素将军";
        }
        if (paramString.equals("壬申")) {
            return "刘旺将军";
        }
        if (paramString.equals("癸酉")) {
            return "康志将军";
        }
        if (paramString.equals("甲戌")) {
            return "施广将军";
        }
        if (paramString.equals("乙亥")) {
            return "任保将军";
        }
        if (paramString.equals("丙子")) {
            return "郭嘉将军";
        }
        if (paramString.equals("丁丑")) {
            return "汪文将军";
        }
        if (paramString.equals("戊寅")) {
            return "曾光将军";
        }
        if (paramString.equals("己卯")) {
            return "龙仲将军";
        }
        if (paramString.equals("庚辰")) {
            return "董德将军";
        }
        if (paramString.equals("辛巳")) {
            return "郑但将军";
        }
        if (paramString.equals("壬午")) {
            return "陆明将军";
        }
        if (paramString.equals("癸未")) {
            return "魏仁将军";
        }
        if (paramString.equals("甲申")) {
            return "方杰将军";
        }
        if (paramString.equals("乙酉")) {
            return "蒋崇将军";
        }
        if (paramString.equals("丙戌")) {
            return "白敏将军";
        }
        if (paramString.equals("丁亥")) {
            return "封济将军";
        }
        if (paramString.equals("戊子")) {
            return "邹镗将军";
        }
        if (paramString.equals("己丑")) {
            return "潘佐将军";
        }
        if (paramString.equals("庚寅")) {
            return "邬桓将军";
        }
        if (paramString.equals("辛卯")) {
            return "范宁将军";
        }
        if (paramString.equals("壬辰")) {
            return "彭泰将军";
        }
        if (paramString.equals("癸巳")) {
            return "徐华将军";
        }
        if (paramString.equals("甲午")) {
            return "章词将军";
        }
        if (paramString.equals("乙未")) {
            return "杨仙将军";
        }
        if (paramString.equals("丙申")) {
            return "管仲将军";
        }
        if (paramString.equals("丁酉")) {
            return "唐杰将军";
        }
        if (paramString.equals("戊戌")) {
            return "姜武将军";
        }
        if (paramString.equals("己亥")) {
            return "谢焘将军";
        }
        if (paramString.equals("庚子")) {
            return "虞起将军";
        }
        if (paramString.equals("辛丑")) {
            return "杨信将军";
        }
        if (paramString.equals("壬寅")) {
            return "贤谔将军";
        }
        if (paramString.equals("癸卯")) {
            return "皮时将军";
        }
        if (paramString.equals("甲辰")) {
            return "李诚将军";
        }
        if (paramString.equals("乙巳")) {
            return "吴遂将军";
        }
        if (paramString.equals("丙午")) {
            return "文哲将军";
        }
        if (paramString.equals("丁未")) {
            return "缪丙将军";
        }
        if (paramString.equals("戊申")) {
            return "徐浩将军";
        }
        if (paramString.equals("己酉")) {
            return "程宝将军";
        }
        if (paramString.equals("庚戌")) {
            return "倪秘将军";
        }
        if (paramString.equals("辛亥")) {
            return "叶坚将军";
        }
        if (paramString.equals("壬子")) {
            return "丘德将军";
        }
        if (paramString.equals("癸丑")) {
            return "朱得将军";
        }
        if (paramString.equals("甲寅")) {
            return "张朝将军";
        }
        if (paramString.equals("乙卯")) {
            return "万清将军";
        }
        if (paramString.equals("丙辰")) {
            return "辛亚将军";
        }
        if (paramString.equals("丁巳")) {
            return "杨彦将军";
        }
        if (paramString.equals("戊午")) {
            return "黎卿将军";
        }
        if (paramString.equals("己未")) {
            return "傅党将军";
        }
        if (paramString.equals("庚申")) {
            return "毛梓将军";
        }
        if (paramString.equals("辛酉")) {
            return "石政将军";
        }
        if (paramString.equals("壬戌")) {
            return "洪充将军";
        }
        if (paramString.equals("癸亥")) {
            return "虞程将军";
        }
        return "";
    }

    /**
     * 所谓命主文昌位，就是根据个人的生辰八字来推算，按照这个方法推算出来的文昌位是跟随个人，永不改变的。个人的命主文昌位如何确定?有这样一个推算的歌诀：甲岁亥巳曲与昌，乙逢马鼠焕文章，丙戊申寅庚亥巳，六丁鸡兔贵非常，壬遇虎猴癸兔西，辛宜子上马名扬。歌诀的意思是：出生在甲年的人，文昌位在东南。出生在乙年，文昌位在正南。出生在丙年，文昌位在西南。出生在丁年，文昌位在正西。出生在戊年，文昌位在西南。出生在己年，文昌位在正西。出生在庚年，文昌位在西北。出生在辛年，文昌位在正北。出生在壬年，文昌位在东北。出生在癸年，文昌位在正东。
     * 人又是如何得知自己出生在那年？这里有一套公式可以推算。凡尾数是4的年份，如2004年，即是甲年。以此类推，尾数是5的年份，即是乙年。尾数是6的年份，即是丙年。尾数是7的年份，即是丁年。尾数是8的年份，即是戊年。尾数是9的年份，即是己年。尾数是0的年份，即是庚年。尾数是1的年份，即是辛年。尾数是2的年份，即是壬年。尾数是3的年份，即是癸年。例如1013年，即是癸年。以自己的出生年份对应上面两个公式来推算，即可知道自己的命主文昌位在哪个位置。
     *
     * @param year 年份
     * @return 文昌位:
     */
    public static String wenchangwei(String year) {
        String returnString = "文昌位:";
        if (String.valueOf(year).startsWith("4", 3)) {
            returnString += "东南";
        }
        if (String.valueOf(year).startsWith("5", 3)) {
            returnString += "南方";
        }
        if (String.valueOf(year).startsWith("6", 3)) {
            returnString += "西南";
        }
        if (String.valueOf(year).startsWith("8", 3)) {
            returnString += "西南";
        }
        if (String.valueOf(year).startsWith("7", 3)) {
            returnString += "西方";
        }
        if (String.valueOf(year).startsWith("9", 3)) {
            returnString += "西方";
        }
        if (String.valueOf(year).startsWith("0", 3)) {
            returnString += "西北";
        }
        if (String.valueOf(year).startsWith("1", 3)) {
            returnString += "北方";
        }
        if (String.valueOf(year).startsWith("2", 3)) {
            returnString += "东北";
        }
        if (String.valueOf(year).startsWith("3", 3)) {
            returnString += "东方";
        }
        return returnString;
    }

    /**
     * 起大运周岁
     * <p>
     * 大运排法: 阳男阴女顺排, 阴男阳女逆排, 离出生日最近的气节。 三天折合一岁计, 即一天折合四个月, 一小时折合五天. 计算时,
     * 如起运总数为18天, 被3除, 等于6, 即为6岁起大运. 如为19天, 则为6岁4个月起大运.
     *
     * @param lunar 八字农历
     * @return
     */
    public static String dayunkaishi(com.nlf.calendar.Lunar lunar, String nianzhu, Sex isman) {
        //甲、丙、戊、庚、壬之年为阳，乙、丁、己、辛、癸之年为阴
        //阴年生男子（或阳年生女子），大运逆行否则顺行
        com.nlf.calendar.JieQi currentJieQi = lunar.getCurrentJieQi();
        Solar s = currentJieQi.getSolar();
        Date jieqiDate = Date.from(Instant.from(LocalDateTime.of(s.getYear(), s.getMonth(),
                                                                 s.getDay(), s.getHour(), s.getMinute(),
                                                                 s.getSecond())));
        Calendar bazi = lunar.getSolar().getCalendar();
        long dayunTime = Math.abs(bazi.getTimeInMillis() - jieqiDate.getTime()) * 120 + bazi.getTimeInMillis();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        return String.format("%s,大运附近节气:%s  %s", format.format(new Date(dayunTime)), currentJieQi.getName(), format.format(jieqiDate));
    }
    
    /**
     * @param man   男方年份字符串
     * @param woman 女方年份字符串
     * @return
     */
    public String hehun(String man, String woman) {
        if (man.length() != 4 || woman.length() != 4) {
            return "输入不正确";
        }
        
        return peihun(man, woman);
        
    }
    
    public String peihun(String manyear, String womanyear) {
        return peihun(getnumber(manyear), getnumber(womanyear));
    }
    
    private String peihun(int manyear, int womanyear) {
        String mang = getnumsix(yearnumber(manyear), Sex.MAN);
        String womang = getnumsix(yearnumber(womanyear), Sex.WOMAN);
        int man = getnumber(mang);
        int woman = getnumber(womang);
        
        
        //数组从0开始，而我们计算从1开始
        man--;
        woman--;
        //注意数组没有第5行和第5列
        if (man >= 5) {
            man--;
        }
        if (woman >= 5) {
            woman--;
        }
        
        //根据表格取结果
        return resultarray[man][woman];//顺序一样的
        
        
    }
    
    /**
     * @param year  年份
     * @param isman 男的么
     * @return 返回宫挂数
     */
    public String getnumsix(String year, Sex isman) {
        
        for (int i = 0; i < 60; i++) {
            if (year.equalsIgnoreCase(numsix[i][0])) {
                
                if (isman == Sex.MAN) {
                    return numsix[i][3];
                } else {
                    return numsix[i][4];
                }
            }
        }
        return null;
        
    }
    
    /**
     * 字符串-》数字
     *
     * @param year 字符串
     * @return 字符串对应数字
     * @throws NumberFormatException
     */
    public int getnumber(String year) throws NumberFormatException {
        
        int yearnumber = Short.parseShort(year);
        return yearnumber;
        
    }
    
    /**
     * 年份取出年柱
     *
     * @param year 年数
     * @return 求的年份的干支
     */
    public String yearnumber(int year) {
        
        //1864年是甲子年，每隔六十年一个甲子
        int idx = (Math.abs(year - 1864)) % 60;
        //没有过春节的话那么年还算上一年的，此处求的年份的干支
        String result = jiazhi[idx];
        return result;
        
    }
}
